#include "stdio.h"
#include "string.h"
#include "sys/socket.h"
#include "netinet/in.h"
#include "stdlib.h"
#include "arpa/inet.h"
#include "errno.h"

#define MAXBUF	128
#define	IP	"127.0.0.1"
#define	PORT	7838

int main(int argc, char **argv)
{
	struct sockaddr_in s_addr;
	int sockfd;
	int addr_len;
	int len;
	char buf[MAXBUF];
	
	sockfd = socket(AF_INET, SOCK_DGRAM, 0);
	if (sockfd == -1){
		perror("socket");
		exit(errno);
	}

	s_addr.sin_family = AF_INET;
	s_addr.sin_port = PORT;
	s_addr.sin_addr.s_addr = inet_addr(IP);
	
	addr_len = sizeof(s_addr);
	strcpy(buf,"hello,iam here!");
	len = sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr *) &s_addr, addr_len);
	if (len < 0) {
		printf("\nsend error.\n");
		return 3;
	}
	printf("send success.\n");
	return 0;
}











